home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-07-08 | 1.3 KB | 35 lines | [TEXT/MPS ] |
- ;--------------------------------------------------------------------------------
- ;
- ; alloca.a -- allocate memory using stack
- ;
- ; Copyright (c) 1993, Anthony C. Ard
- ;
- ; This program is free software; you can redistribute it and/or
- ; modifiy it under the terms of the GNU General Public License
- ; as published by the Free Software Foundation; either version 2
- ; of the License, or (at your option) any later version.
- ;
- ; This program is distributed in the hope that it will be useful,
- ; but WITHOUT ANY WARRANTY; without even the implied warranty of
- ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ; GNU General Public License for more details.
- ;
- ; You should have received a copy of the GNU General Public License
- ; along with this program; if not, write to the Free Software
- ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- ;
- ;--------------------------------------------------------------------------------
-
- alloca proc export
-
- move.l (sp)+,a0 ; pop return addr from top of stack
- move.l (sp)+,d0 ; pop size in bytes from top of stack
- add.l #3,d0 ; round size up to long word
- and.l #-4,d0 ; mask out lower two bits
- sub.l d0,sp ; allocate by moving the stack pointer
- move.l sp,d0 ; pointer to the allocated block
- add.l #-4,sp ; new top of stack
- jmp (a0) ; don't use stack to return
-
- end
-